﻿<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" BorderThickness="0"
    x:Class="SUT.PrintEngine.Views.PrintControlView"
    VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
    MinWidth="700" MinHeight="500" Background="#FFEBEBEB" >
    <UserControl.Resources>
        <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
    </UserControl.Resources>
    <Border Margin="15">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <Grid x:Name="MainPane" Grid.Row="0" >
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="*" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Border Grid.Column="0" Grid.Row="0" x:Name="TopPane" BorderThickness="1" BorderBrush="#949494">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <Border x:Name="ToolBar" Height="35" BorderBrush="#FFA8A8A8" BorderThickness="2">
                            <DockPanel LastChildFill="False">
                                <Button DockPanel.Dock="Right" IsTabStop="True" TabIndex="5" x:Name="ActualSizeButton" ToolTip="100%" VerticalAlignment="Center" Width="75" Command="{Binding ActualPageSizeCommand}" ToolTipService.ShowOnDisabled="True" Content="Actual Size" Margin="0,0,5,0" Style="{DynamicResource DefaultButtonStyle}" Height="25"/>
                                <Button DockPanel.Dock="Right" IsTabStop="True" TabIndex="8" x:Name="AllPagesButton" ToolTip="Show All Pages" VerticalAlignment="Center" Width="75" Command="{Binding AllPagesCommand}" ToolTipService.ShowOnDisabled="True" HorizontalAlignment="Stretch" Content="All Pages" Margin="0,0,5,0" Style="{DynamicResource DefaultButtonStyle}" Height="25"/>
                                <Menu Cursor="Hand" DockPanel.Dock="Right" Margin="0,0,5,0" VerticalAlignment="Center" Height="25" Background="{x:Null}" >
                                    <MenuItem Header="Printing Options" VerticalAlignment="Center" Style="{DynamicResource MenuItemStyle}" Height="25" Width="108.893">
                                        <MenuItem Style="{DynamicResource MenuItemStyle}" Template="{DynamicResource {ComponentResourceKey ResourceId=SubmenuItemTemplateKey, TypeInTargetAssembly={x:Type MenuItem}}}">
                                            <MenuItem.Header>
                                                <Grid>
                                                    <Border x:Name="PrintingOptionsWaitCurtain" Panel.ZIndex="1" Height="Auto" Background="White" Opacity="0.9" Visibility="Collapsed">
                                                        <Label Content="Please Wait..." HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Red" FontSize="14.667"/>
                                                    </Border>
                                                    <Border Width="Auto" Height="Auto" BorderThickness="1,0,1,1" BorderBrush="#ffffff" Margin="0,0,0,0">
                                                        <Border.Background>
                                                            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                                                <GradientStop Color="#FFE8E7E7" Offset="1"/>
                                                                <GradientStop Color="#FFFFFFFF" Offset="0"/>
                                                                <GradientStop Color="#FFFFFDFD" Offset="0.5"/>
                                                            </LinearGradientBrush>
                                                        </Border.Background>
                                                        <Border.BitmapEffect>
                                                            <DropShadowBitmapEffect Noise="0.09" Color="#FF474242" ShadowDepth="2"/>
                                                        </Border.BitmapEffect>
                                                        <StackPanel Orientation="Vertical" Margin="5" >
                                                            <StackPanel Orientation="Vertical" Width="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Center">
                                                                <Label Padding="0,0,0,2"  FontFamily="Verdana" Foreground="Black" FontWeight="Bold" FontSize="10" Margin="0,0,0,0" HorizontalAlignment="Left" Content="Paper Size" />
                                                                <StackPanel Orientation="Horizontal">
                                                                    <Label x:Name="PaperType"
                                  Width="150"
                                  Padding="0,5,0,2"  
                                  HorizontalAlignment="Left"                                  
                                  Content="{Binding Path=CurrentPaper.PaperName, Mode=TwoWay}" />
                                                                    <Button Content="Change" Cursor="Hand" Command="{Binding ChangePaperCommand}" Style="{DynamicResource DefaultButtonStyle}" Width="60" />
                                                                </StackPanel>
                                                            </StackPanel>
                                                            <Rectangle Height="1" Fill="#FFDADBDC" Margin="0,10,0,0" />
                                                            <Rectangle Height="1" Fill="#FFEBEDED" Margin="0,0,0,5" />
                                                            <StackPanel Orientation="Vertical" VerticalAlignment="Stretch">
                                                                <Label Padding="0,0,0,2"  FontFamily="Verdana" Foreground="Black" FontWeight="Bold" FontSize="10" Margin="0,0,0,0" HorizontalAlignment="Stretch" Content="Orientation" />
                                                                <StackPanel Orientation="Horizontal">
                                                                    <RadioButton Cursor="Hand" GroupName="PreviewPageOrientation" x:Name="Portrait" Content="Portrait" FontSize="9" Margin="0,2,10,0" IsChecked="True" Command="{Binding Path=PageOrientationCommand}" CommandParameter="Portrait" />
                                                                    <RadioButton Cursor="Hand" GroupName="PreviewPageOrientation" x:Name="Landscape" Content="Landscape" FontSize="9" Margin="20,2,20,0"  Command="{Binding Path=PageOrientationCommand}" CommandParameter="Landscape"/>
                                                                </StackPanel>
                                                            </StackPanel>
                                                            <Rectangle Fill="#FFCFD8DA" StrokeThickness="0"  Margin="0,10,0,0" VerticalAlignment="Top" Height="1" />
                                                            <Rectangle Height="1" Fill="#eeeeee" Margin="0,0,0,10" />
                                                            <Border Margin="0,-1,2,0" BorderThickness="1" BorderBrush="#cccccc" CornerRadius="0,5,5,5" Background="#FFFDDB" d:LayoutOverrides="Width">
                                                            	<StackPanel Orientation="Vertical" Margin="8,0,0,0">
                                                            		<StackPanel Orientation="Vertical">
                                                            			<StackPanel Orientation="Horizontal">
                                                            				<Label Padding="0,0,0,2"  FontFamily="Verdana" Foreground="Black" FontWeight="Bold" FontSize="10" Margin="0,15,0,0" HorizontalAlignment="Left" Content="Select Printer" />
                                                            			</StackPanel>
                                                            			<StackPanel Orientation="Horizontal">
                                                            				<ComboBox Cursor="Hand" x:Name="PrinterList" Margin="0,5,0,0" Width="150"
                                                            					HorizontalAlignment="Left"
                                                            					ItemsSource="{Binding Printers}"
                                                            					SelectedItem="{Binding CurrentPrinter, Mode=TwoWay}"
                                                            					SelectedValuePath="FullName"
                                                            					DisplayMemberPath="FullName"/>
                                                            				<ContentControl Cursor="Hand" Margin="0,5,0,0" HorizontalAlignment="Left" Content="Error" Visibility="Hidden"/>
                                                            			</StackPanel>
                                                            		</StackPanel>
                                                            		<DockPanel LastChildFill="False" Margin="0,0,0,15">
                                                            			<StackPanel DockPanel.Dock="Left" Orientation="Vertical">
                                                            				<Label Padding="0,0,0,2"  FontFamily="Verdana" Foreground="Black" FontWeight="Bold" FontSize="10" Margin="0,10,0,0" HorizontalAlignment="Left" Content="Copies" />
                                                            				<TextBox Width="25" Margin="0,5,0,0" HorizontalAlignment="Left"  Height="20" Text="{Binding PrintCopyCount, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                                                            			</StackPanel>
                                                            			<StackPanel Visibility="Collapsed" Orientation="Vertical"  Margin="5,0,30,0" DockPanel.Dock="Right">
                                                            				<Label Padding="0,0,0,2"  FontFamily="Verdana" Foreground="Black" FontWeight="Bold" FontSize="10" Margin="0,10,0,0" HorizontalAlignment="Left" Content="Range" />
                                                            				<StackPanel Orientation="Horizontal" Margin="0,5,0,0">
                                                            					<TextBox  Width="25" Height="18" Text="{Binding PageRangeStart, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                                                            					<Label Padding="0,0,0,2"  FontFamily="Verdana" Foreground="Black" FontSize="10" Margin="5,5,0,0" HorizontalAlignment="Left" Content="to" />
                                                            					<TextBox Width="25" Margin="5,0,0,0" Height="18" Text="{Binding PageRangeEnd, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                                                            				</StackPanel>
                                                            			</StackPanel>
                                                            		</DockPanel>
                                                            		<CheckBox Cursor="Hand" x:Name="PageNumberMarker" Visibility="Collapsed" Margin="0,0,10,10" IsChecked="{Binding IsMarkPageNumbers, Mode=TwoWay}">
                                                            			<Label Padding="3,0,0,0" FontSize="9" Foreground="Black" Margin="0,0,0,0" Content="Mark Page Positions" FontWeight="Bold"/>
                                                            		</CheckBox>
                                                            	</StackPanel>
                                                            </Border>
                                                            <Rectangle Fill="#cfd8da" StrokeThickness="0"  Margin="0,10,0,0" VerticalAlignment="Top" Height="1" />
                                                            <Rectangle Fill="#ffffff" StrokeThickness="0"  Margin="0,0,0,0" VerticalAlignment="Top" Height="1" />
                                                            <DockPanel LastChildFill="False" Margin="0,10,0,0">
                                                                <Button Cursor="Hand" DockPanel.Dock="Left" x:Name="CancelSetButton" Command="{Binding Path=CancelPrintingOptionsCommand}" Content="Cancel" Style="{DynamicResource DefaultButtonStyle}" Width="60" />

                                                                <StackPanel x:Name="SetPanel" DockPanel.Dock="Right">
                                                                    <Button Cursor="Hand" x:Name="SetButton" Command="{Binding Path=SetPrintingOptionsCommand}" Content="Set" Style="{DynamicResource DefaultButtonStyle}" Width="60"  />
                                                                </StackPanel>
                                                            </DockPanel>
                                                        </StackPanel>
                                                    </Border>
                                                </Grid>
                                            </MenuItem.Header>
                                        </MenuItem>
                                    </MenuItem>
                                </Menu>
                                <Menu x:Name="ScaleMenu" Cursor="Hand" DockPanel.Dock="Right" Margin="0,0,5,0"  Visibility="{Binding CanScale,Converter={StaticResource BooleanToVisibilityConverter}}" VerticalAlignment="Center" Height="25" Background="{x:Null}" Width="60">
                                    <MenuItem Header="Print Size" Height="25" Width="60">
                                        <MenuItem Style="{DynamicResource MenuItemStyle}" Template="{DynamicResource {ComponentResourceKey ResourceId=SubmenuItemTemplateKey, TypeInTargetAssembly={x:Type MenuItem}}}">
                                            <MenuItem.Header>
                                                <Border Width="Auto" Height="Auto" BorderThickness="1,0,1,1" BorderBrush="#ffffff" Margin="0,0,0,0">
                                                    <Border.Background>
                                                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                                            <GradientStop Color="#FFE8E7E7" Offset="1"/>
                                                            <GradientStop Color="#FFFFFFFF" Offset="0"/>
                                                            <GradientStop Color="#FFFFFDFD" Offset="0.5"/>
                                                        </LinearGradientBrush>
                                                    </Border.Background>
                                                    <Border.BitmapEffect>
                                                        <DropShadowBitmapEffect Noise="0.09" Color="#FF474242" ShadowDepth="2"/>
                                                    </Border.BitmapEffect>
                                                    <StackPanel Orientation="Vertical" Margin="5" HorizontalAlignment="Center" VerticalAlignment="Center">
                                                        <StackPanel Visibility="{Binding Path=ScaleSliderVisibility}" Orientation="Vertical" Width="200" Margin="0,5,0,5">
                                                            <Grid>
                                                                <Grid.ColumnDefinitions>
                                                                    <ColumnDefinition Width="Auto"/>
                                                                    <ColumnDefinition Width="*"/>
                                                                    <ColumnDefinition Width="Auto"/>
                                                                </Grid.ColumnDefinitions>
                                                                <Grid.RowDefinitions>
                                                                    <RowDefinition Height="Auto"/>
                                                                    <RowDefinition Height="Auto"/>
                                                                    <RowDefinition Height="Auto"/>
                                                                </Grid.RowDefinitions>
                                                                <StackPanel Orientation="Vertical" Grid.Column="0" Grid.Row="0">
                                                                    <Label Padding="0,0,0,0" FontFamily="Verdana" Foreground="Black" FontSize="9" FontWeight="Bold" Margin="0,0,0,0" HorizontalAlignment="Left" Content="Small" />
                                                                    <Label Padding="0,0,0,0" FontFamily="Verdana" Foreground="#666666" FontSize="9" Margin="0,0,0,0" HorizontalAlignment="Left" Content="Less pages" />
                                                                </StackPanel>
                                                                <StackPanel Orientation="Vertical" Grid.Column="2" Grid.Row="0">
                                                                    <Label Padding="0,0,0,0" FontFamily="Verdana" Foreground="Black" FontSize="9" FontWeight="Bold" Margin="0,0,0,0" HorizontalAlignment="Right" Content="Big" />
                                                                    <Label Padding="0,0,0,0" FontFamily="Verdana" Foreground="#666666" FontSize="9" Margin="0,0,0,0" HorizontalAlignment="Right" Content="More pages" />
                                                                </StackPanel>
                                                            </Grid>
                                                            <Slider Cursor="Hand"  x:Name="PageNumbersSlider" Margin="0,5,0,0" Minimum="0.1" Maximum="1" Value="{Binding Path=Scale, Mode=TwoWay}" />
                                                        </StackPanel>
                                                        <Grid x:Name="ScalePreviewBox" Width="200" Height="100" Background="White" Opacity="1" >
                                                            <Border BorderThickness="1" BorderBrush="#cccccc">
                                                                <DockPanel>
                                                                    <Grid x:Name="PreviewNode" Width="90" Height="51" HorizontalAlignment="Center" VerticalAlignment="Center">
                                                                        <Grid Width="90" Height="51">
                                                                            <Rectangle Fill="#FFE4FFAE" Stroke="#cccccc" />
                                                                            <Label Content="Content"
                 HorizontalAlignment="Center"
                 VerticalAlignment="Center"
                 FontFamily="Arial"
                 FontSize="14"
                 Foreground="Black"/>
                                                                        </Grid>
                                                                    </Grid>
                                                                </DockPanel>
                                                            </Border>
                                                        </Grid>
                                                        <Rectangle Fill="#cfd8da" StrokeThickness="0"  Margin="0,10,0,0" VerticalAlignment="Top" Height="1" />
                                                        <Rectangle Fill="#ffffff" StrokeThickness="0"  Margin="0,0,0,0" VerticalAlignment="Top" Height="1" />
                                                        <DockPanel LastChildFill="False" Margin="0,10,0,0">
                                                            <Button Cursor="Hand" DockPanel.Dock="Left" IsEnabled="False"  Content="Cancel" Command="{Binding Path=CancelScaleCommand}" Style="{DynamicResource DefaultButtonStyle}" Width="60" />
                                                            <Button Cursor="Hand" DockPanel.Dock="Right" Command="{Binding Path=ApplyScaleCommand}" Content="Apply" Style="{DynamicResource DefaultButtonStyle}" Width="60" />
                                                        </DockPanel>
                                                    </StackPanel>
                                                </Border>
                                            </MenuItem.Header>
                                        </MenuItem>
                                    </MenuItem>
                                </Menu>
                            </DockPanel>
                        </Border>
                        <ScrollViewer x:Name="sv" IsDeferredScrollingEnabled="False" Grid.Row="1" CanContentScroll="True" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
                            <Border Background="DarkGray" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" BorderThickness="2,0,2,2" BorderBrush="#FFEBEBEB">
                                <StackPanel x:Name="PagePreviewContainer"
                  Background="Gray"
                  ScrollViewer.CanContentScroll="false"
                  Orientation="Vertical"
                  HorizontalAlignment="Center"
                  VerticalAlignment="Center"/>
                            </Border>
                        </ScrollViewer>

                    </Grid>
                </Border>
            </Grid>
            <Grid x:Name="ButtonPane" Grid.Row="1">
                <StackPanel HorizontalAlignment="Left" VerticalAlignment="Center" Orientation="Horizontal" Margin="10"  >
                    <Label Content="Requires :" FontSize="12" Foreground="#FF181313" />
                    <Label x:Name="PageNumber" Content="{Binding Path=ApproaxNumberOfPages}" FontSize="12" Foreground="#FF430000" />
                    <Label x:Name="PageName" Content="{Binding Path=CurrentPaper.PaperName}" FontSize="12" Foreground="#FF181313" />
                    <Label Content="pages" FontSize="12" Foreground="#FF181313" />
                    <Label Content="in" FontSize="12" Foreground="#FF181313" />
                    <Label x:Name="Orientation" Content="{Binding Path=PageOrientationString}" FontSize="12" Foreground="#FF430000" />
                    <Label Content="at printer : " FontSize="12" Foreground="#FF181313" />
                    <TextBlock x:Name="PrinterName" Text="{Binding Path=CurrentPrinterName, Mode=OneWay}" ToolTip="{Binding Path=CurrentPrinterName, Mode=OneWay}" TextTrimming="CharacterEllipsis" MaxWidth="220" VerticalAlignment="Center" Padding="0"  FontSize="12" Foreground="#FF430000" MinWidth="10" />
                </StackPanel>
                <StackPanel HorizontalAlignment="Right" Orientation="Horizontal" Margin="10"  >
                    <Button HorizontalAlignment="Right" Command="{Binding Path=CancelPrintCommand}" Content="Cancel" Style="{DynamicResource DefaultButtonStyle}" Width="60"/>
                    <TextBlock Margin="10,0" Text="Or"  VerticalAlignment="Center"/>
                    <Button IsDefault="True"  HorizontalAlignment="Right" Command="{Binding Path=PrintDocumentCommand}" Content="Print" Style="{DynamicResource DefaultButtonStyle}" Width="60"/>
                </StackPanel>
            </Grid>
        </Grid>
    </Border>
</UserControl>
